package packing;

import geometric3D.Point;
import geometric3D.XYRectangle;
import geometric3D.XZRectangle;
import geometric3D.YZRectangle;

public class PositionSimpleBlockPair {
	
	Point position;
	SimpleBlock simpleblock;
	
	@Override
	public String toString() {
		return "PositionSimpleBlockPair [position=" + position
				+ ", simpleblock=" + simpleblock + "]";
	}

	public PositionSimpleBlockPair(Point position, SimpleBlock simpleblock) {
		super();
		this.position = position;
		this.simpleblock = simpleblock;
	}

	public Point getPosition() {
		return position;
	}

	public SimpleBlock getSimpleblock() {
		return simpleblock;
	}
	
	public XZRectangle getXZRectangle (boolean isPositiveFaced){
		BoxPack box = simpleblock.getBox();
		int xBoxNumber = simpleblock.getxBoxNumber();
		int yBoxNumber = simpleblock.getyBoxNumber();
		int zBoxNumber = simpleblock.getzBoxNumber();
		
		if (isPositiveFaced) {
			return new XZRectangle(new Point(position.getX(), position.getY()+box.getLength()*yBoxNumber, position.getZ()), 
					box.getWidth()*xBoxNumber, box.getHeight()*zBoxNumber, true);
		}else {
			return new XZRectangle(position, 
					box.getWidth()*xBoxNumber, box.getHeight()*zBoxNumber, true);
		}
	}
	
	public XYRectangle getXYRectangle (boolean isPositiveFaced){
		BoxPack box = simpleblock.getBox();
		int xBoxNumber = simpleblock.getxBoxNumber();
		int yBoxNumber = simpleblock.getyBoxNumber();
		int zBoxNumber = simpleblock.getzBoxNumber();
		if (isPositiveFaced) {
			return new XYRectangle(new Point(position.getX(), position.getY(), position.getZ()+box.getHeight()*zBoxNumber),
					box.getWidth()*xBoxNumber, box.getLength()*yBoxNumber, true);
		}else{
			return new XYRectangle(position,
					box.getWidth()*xBoxNumber, box.getLength()*yBoxNumber, false);
		}
			
	}
	public YZRectangle getYZRectangle(boolean isPositiveFaced){
		BoxPack box = simpleblock.getBox();
		int xBoxNumber = simpleblock.getxBoxNumber();
		int yBoxNumber = simpleblock.getyBoxNumber();
		int zBoxNumber = simpleblock.getzBoxNumber();
		if(isPositiveFaced){
			return new YZRectangle(new Point(position.getX()+box.getWidth()*xBoxNumber, position.getY(), position.getZ()),
					box.getLength()*yBoxNumber, box.getHeight()*zBoxNumber, true);
		}else{
			return new YZRectangle(position,
					box.getLength()*yBoxNumber, box.getHeight()*zBoxNumber, false);
		}
	}

}
